ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
6

How to save file to the current directory with roslaunch?

asked 2013-03-04 20:57:36 -0600

i write a simple C++ program to save an image

cv::imwrite(filename,visual_img);

when i run it directly from Eclipse, the image is saved in the current directory (the directory where the Eclipse project file is in). but when i run it with roslaunch

<node pkg="testProg" type="testProg" name="testProg" />

the image is saved in home/.ros

so what should i do to save it to the current directory?

p.s. i encounter the same problem when i try to load the image. always fail to load if i put the image in the current directory when i run it by roslaunch.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
14

answered 2013-03-05 05:31:58 -0600

See the attributes section on the roslaunch wiki page.

Using the "cwd" attribute, you can specify that the node should be started using the executable's directory as its working-directory. The default behavior is to use $ROS_HOME directory.

For example:

<launch>
  <node name="test" pkg="my_package" type="my_node" cwd="node" />
</launch>
edit flag offensive delete link more

Comments

a million thanks! it works.

yangyangcv gravatar image yangyangcv  ( 2013-03-05 11:42:20 -0600 )edit

However, it is generally better to use $ROS_HOME subdirectories for files you want to write.

joq gravatar image joq  ( 2013-03-05 14:31:43 -0600 )edit
6

answered 2015-11-11 09:02:55 -0600

lucasw gravatar image

This is what I do to run the nodes in the current directory:

ROS_HOME=`pwd` roslaunch foo.launch
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-03-04 20:57:36 -0600

Seen: 12,207 times

Last updated: Nov 11 '15